package cn.vihub.service.impl;

import cn.vihub.param.ShopBrandInfoParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.vihub.pojo.ShopBrandInfo;
import cn.vihub.service.ShopBrandInfoService;
import cn.vihub.mapper.ShopBrandInfoMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 64452
* @description 针对表【shop_brand_info(商品品牌数据表)】的数据库操作Service实现
* @createDate 2025-07-23 14:35:22
*/
@Service
public class ShopBrandInfoServiceImpl extends ServiceImpl<ShopBrandInfoMapper, ShopBrandInfo>
    implements ShopBrandInfoService{

    @Value("${minio.imgurl}")
    private String minioImgUrl;


    @Override
    public IPage<ShopBrandInfo> selectByPage(ShopBrandInfoParam shopBrandInfoParam) {
        IPage<ShopBrandInfo> iPage = new Page<>(shopBrandInfoParam.getPage(), shopBrandInfoParam.getLimit());
        LambdaQueryWrapper<ShopBrandInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(StringUtils.isNotBlank(shopBrandInfoParam.getName()), ShopBrandInfo::getName, shopBrandInfoParam.getName());
        // 执行分页查询
        IPage<ShopBrandInfo> page = page(iPage, lambdaQueryWrapper);

        // 处理图片，给图片加前缀
        // for (ShopBrandInfo shopBrandInfo : page.getRecords()){
        //
        //     String pic = minioImgUrl +"/"+ shopBrandInfo.getPic();
        //
        //     shopBrandInfo.setPic(pic);
        // }

        return page;
    }
}




